import 'area_list.dart';

class AreaModel {
  String? code;
  int? level;
  String? name;
  List<CityModel>? areaList;

  AreaModel({this.code, this.level, this.name, this.areaList});

  factory AreaModel.fromJson(Map<String, dynamic> json) => AreaModel(
        code: json['code'] as String?,
        level: json['level'] as int?,
        name: json['name'] as String?,
        areaList: (json['areaList'] as List<dynamic>?)
            ?.map((e) => CityModel.fromJson(e as Map<String, dynamic>))
            .toList(),
      );

  Map<String, dynamic> toJson() => {
        'code': code,
        'level': level,
        'name': name,
        'areaList': areaList?.map((e) => e.toJson()).toList(),
      };
}
